{% extends "base.html" %} {% block main %}
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><span class="glyphicon glyphicon-user"></span> Please sign in</h3>
                </div>
                <div class="panel-body">
                    <form method="post">
                        <div class="form-group">
                            <label>UserName</label>
                            <input type="text" name="userName" class="form-control" placeholder="username">
                            <p class="help-block">UserName: admin</p>
                        </div>
                        <div class="form-group">
                            <label>Password</label>
                            <input type="password" name="password" class="form-control" placeholder="Password">
                            <p class="help-block">Use password: 123</p>
                        </div>
                        <input type="button" class="btn btn-primary" value="Sign in" onclick="login()">
                        <!-- <button type="submit" class="btn btn-primary" >Sign In</button> -->
                    </form>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <ul>
                {% for item in list %}
                <li>{{item}}</li>
                {% endfor %}
            </ul>
        </div>
    </div>
</div>
<script>
async function login(){
    var temp;
    let {code, msg} = await _http("post", '/login', {userName: '张三', password: 12321})
    if(code === 100){
        window.location.href = '/ok'
    }
}
async function _http(method,url, data ){
    try {
        return await $.ajax({
            async: false,
            type: method,
            url: url,
            dataType: 'json',
            data:data
        });
    } catch (error) {
        console.log('error : ',error)
    }
}
</script>
{% endblock %}